#include <ros/ros.h>
#include "fyt_msg/AllTargets.h"
#include <opencv2/opencv.hpp>

static cv::Mat src;

void detectorCallBack(const fyt_msg::AllTargetsConstPtr &msg){
    src=cv::Mat::zeros(cv::Size(1280,1280),CV_8UC3);
    for(int i=0;i<msg->len;i++){
        cv::Rect rect(msg->rect[i].x,msg->rect[i].y,msg->rect[i].width,msg->rect[i].height);
        cv::rectangle(src,rect,cv::Scalar(255,255,255),3);
        cv::putText(src,std::to_string(msg->id[i]),
            cv::Point(msg->rect[i].x+0.5*msg->rect[i].width,msg->rect[i].y+0.5*msg->rect[i].height)
            ,1,4,cv::Scalar(255,255,255),4); 
    }

    cv::imshow("src",src);
    cv::waitKey(1);
}

int main(int argc, char **argv){
    ros::init(argc, argv,"test_detector_node");
    ros::NodeHandle n;
    ros::Subscriber sub=n.subscribe("all_targets",1,detectorCallBack);
    ros::spin();
}